﻿@model Model.Usuario



<div align="center">
    <br /><br /><br />
    <img src="~/Content/images/usuarios.png" />
    <fieldset>

        <br /><br />
        <legend></legend>

        <form method="post" role="form">
            <div class="form-group">
                @Html.LabelFor(x => x.username)
                <input class="form-control" placeholder="Ingrese Nombre" type="text" name="username" />
                @*@Html.TextBoxFor(x => x.username)*@
                @Html.ValidationMessageFor(x => x.username)
            </div>
            <div class="form-group">
                @Html.LabelFor(x => x.realName)
                <input class="form-control" placeholder="Ingrese nombre real" type="text" name="realName" />
                @*@Html.TextBoxFor(x => x.realName)*@
                @Html.ValidationMessageFor(x => x.realName)
            </div>
            <div class="form-group">
                @Html.LabelFor(x => x.mail)
                <input class="form-control" placeholder="Ingrese e-mail" type="text" name="mail" />
                @*@Html.TextBoxFor(x => x.mail)*@
                @Html.ValidationMessageFor(x => x.mail)
            </div>
            <div class="form-group">
                @Html.LabelFor(x => x.idCodigo)
               
                <input class="form-control" placeholder="Ingrese Codigo de Empresa" type="text" id="idCodigo" name="idCodigo" onkeypress="setTimeout(consultarEmpresa,0)"  />
                @*@Html.TextBoxFor(x => x.idCodigo, new { onkeypress = "setTimeout(consultarEmpresa,0)" })*@
                @Html.ValidationMessageFor(x => x.idCodigo)

                


            </div>
            <span id="nombreEmpresa"></span>

            <div class="form-group">
                <label>Password</label>
                <input class="form-control" placeholder="Ingrese Contraseña" type="password" name="password" />
            </div>

            <input type="submit" />

        </form>
    </fieldset>
    </div>

    <script type="text/javascript">

        function consultarEmpresa() {


            var idV = $("#idCodigo").val();
            var parametros = {
                id: idV
            }

            var promise = $.get("@Url.Action("consultarIdEmpresa", "Usuario")", parametros);
            promise.done(mostrarNombreEmpresa);
        }

        function mostrarNombreEmpresa(datos) {


            $("#nombreEmpresa").html(datos.nombre)

        }

    </script>
